#ifndef __TASK_H__
#define __TASK_H__
#include <memory>
#include <functional>

class Task
{
public:
	Task();
	virtual ~Task();

	unsigned int GetId() const { return id_; }

	void* GetOwner() const { return owner_; }
	void SetOwner(void* v) { owner_ = v; }

	int GetPriority() const { return priority_; }
	void SetPriority(int v) { priority_ = v; }

protected:
	virtual bool OnSchedule();
	virtual void OnComplete();

protected:
	unsigned int id_;
	void* owner_;
	int priority_;

	friend class Service;

};

class SimpleTask : public Task
{
public:

	void SetCompleteFunction(const std::function<void()>& func);

protected:
	virtual void OnComplete();

	std::function<void()> completeFunc_;
};

class AsynSimpleTask : public Task
{
public:

	void SetAsynFunction(const std::function<void()>& func);

protected:
	virtual bool OnSchedule();

	std::function<void()> asynFunc_;
};


#endif // __TASK_H__